home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / PET / S-Super PET / (s)tk.d64 / READ16.ASM < prev    next >
Assembly Source File  |  2009-01-18  |  1KB  |  29 lines

  1.  ;subroutine read16. used in main routine adump.
  2.         xdef read16             ;definition for external use
  3.         xref getchar_           ;reference to system routine
  4.         size equ $10            ;buffer size is 17 (16 plus 1)
  5.  
  6.  
  7. read16  stx storage             ;store buffer address
  8.         ldd #size
  9.         addd storage
  10.         std storage
  11.         loop                    ;loop
  12.            pshs x               ;   push address of buffer
  13.            jsr getchar_         ;   read character from keyboard
  14.            puls x               ;   pull buffer address
  15.            cmpb #$0d            ;   is character a carriage return?
  16.            quif eq              ;   quit if it is
  17.            stb ,x               ;   store character
  18.            cmpx storage         ;   is buffer full?
  19.            quif eq              ;   quit if it is
  20.            leax 1,x
  21.         endloop                 ;endloop
  22.         lda #0                  ;store a zero
  23.         sta ,x                  ;convert end of string to zero
  24.         rts
  25.         end
  26.  
  27. storage rmb 2
  28.  
  29.